package ZuoYe1;

import java.util.Arrays;

/**
 * @name 菠菜
 * @date 2024-08-31 23:24
 */



/*
知识点：数组，循环，if，边界
    创建100个学⽣对象，id编号为1~100
    把编号可以⼤于60的归为⼆组，其他的归为⼀组
知识点: switch
定义⼀个⽅法，给1~4其中⼀个数字，返回春夏秋冬 字符串，不命中则返回 错误季节

知识点 static ，数组， 循环
定义⼀个Dog类，⾥⾯含有 age 静态变量初始为 10，有⼀个name成员属性 , 有⼀个
changeAge⽅法，使age⾃增1， 创建含5个dog的数组，获取数组⻆标为3的dog对象,调⽤两
次changeAge⽅法，最后打印5个dog对象的age分别是多少*/
public class AnswerTest {
    public static void main(String[] args) {
//        test2();
//        test3();
//        Student student = new Student();

    }

    public static void test3() {
        Dog [] dogs = new Dog[5];
        for (int i = 0; i < 5; i++){
            Dog dog = new Dog();
            dog.setName("旺财" + i);
            dogs[i] = dog;

        }
        Dog dog = dogs[3];
        dog.changeAge();
        dog.changeAge();
        for (Dog d : dogs){
            System.out.println("名称="+d.getName()+", age="+d.getAge());
        }

    }

    public static void test2() {
        // 第二题答案
        int season = 1;
        String content = "";

        switch (season){
            case 1: content = "春";
                break;
            case 2: content = "夏";
                break;
            case 3: content = "秋";
                break;
            case 4: content = "冬";
                break;
            default: {
                content = "错误季节";
                System.out.println("default执行");
            }
        }
        System.out.println(content);
    }





    public static void test1() {
        // 第一题答案
         // 第一个知识点
        Student[] arr1 = new Student[60];
        int arr1index = 0;
        Student[] arr2 = new Student[60];
        int arr2index = 0;
        for (int i = 0; i < 100; i++){
            int num = i+1;
            Student student = new Student();
            student.setId(num);
            if (num < 60){
                arr1[arr1index] = student;
                arr1index++;
            } else if (num > 60) {
                arr2[arr2index] = student;
                arr2index++;

            }

        }
        System.out.println("arr1index的数据：");
        System.out.println(Arrays.toString(arr1));
        System.out.println("arr2index的数据：");
        System.out.println(Arrays.toString(arr2));
        for (Student s : arr1){
            System.out.println(s.getId());
        }
        System.out.println("---------------------------------------");
        for (Student s : arr2){
            System.out.println(s.getId());
        }

    }

}
